package ge.unihack.instantdj.protocol.common;

import ge.unihack.instantdj.utils.HttpUtils;
import ge.unihack.instantdj.utils.NetworkUtils;

import java.io.IOException;

public class CloudNotifier {

	private String cloudUrl = "";
	
	public void notifyCloud() throws IOException {
		notifyCloud(cloudUrl);
	}
	
	public void notifyCloud(String url) throws IOException {
		String ip = NetworkUtils.getIPAddress();
		int code = HttpUtils.get(cloudUrl, HttpUtils.newMap("address", ip));
		if (!HttpUtils.isOk(code)) {
			throw new IOException("Unable to submit local ip to cloud");
		}
	}

}
